/*****************************************************************************//*!
* file  : sysprint.c
* creat : apleilx
* data  : 20200408
* src   : 该文件由rtthread shell输出相关函数修改而来， 不支持浮点数打印。
*******************************************************************************/
#include "stdint.h"
#include "stdio.h"
#include "stdarg.h"
#include "string.h"
#include "os_obj.h"

void sys_hw_console_output(const char *str);

/**
 * This function will put string to the console.
 *
 * @param str the string output to the console.
 */
void sys_kputs(const char *str)
{
    if (!str) return;

    osMutexWait(os_obj.mid_printf, 1000);

    sys_hw_console_output(str);

    osMutexRelease(os_obj.mid_printf);
}

/**
 * This function will print a formatted string on system console
 *
 * @param fmt the format
 */
static char  buf_str[240 + 1]; 
void sys_kprintf(const char *fmt, ...)
{
    va_list   v_args;

	osMutexWait(os_obj.mid_printf, 1000);
	
    va_start(v_args, fmt);
   (void)vsnprintf((char       *)	&buf_str[0],
                   (size_t      )	sizeof(buf_str)-5,
                   (char const *)	fmt,
                                 	v_args);
    va_end(v_args);
    
    sys_hw_console_output(buf_str);
	
	osMutexRelease(os_obj.mid_printf);
}



